1 #region Using Statements
3 using System.Collections.Generic;
4 using Microsoft.Xna.Framework;
5 using Microsoft.Xna.Framework.Content;
6 using Microsoft.Xna.Framework.Graphics;
7 using Microsoft.Xna.Framework.Input;
8 using Microsoft.Xna.Framework.Storage;
9 using Microsoft.Xna.Framework.GamerServices;
13 namespace SuperPolarity
16 /// This is the main type for your game
18 public class SuperPolarity : Game
20 public static GraphicsDeviceManager graphics;
21 SpriteBatch spriteBatch;
23 public static int OutlierBounds;
25 public SuperPolarity()
28 SuperPolarity.graphics = new GraphicsDeviceManager(this);
29 SuperPolarity.graphics.PreferMultiSampling = true;
30 Content.RootDirectory = "Content";
31 ActorFactory.SetGame(this);
32 ParticleEffectFactory.SetGame(this);
33 ActorManager.SetGame(this);
37 /// Allows the game to perform any initialization it needs to before starting to run.
38 /// This is where it can query for any required services and load any non-graphic
39 /// related content. Calling base.Initialize will enumerate through any components
40 /// and initialize them as well.
42 protected override void Initialize()
48 InputController.RegisterEventForButton("changePolarity", Buttons.A);
49 InputController.RegisterEventForKey("changePolarity", Keys.Z);
51 InputController.RegisterEventForButton("shoot", Buttons.X);
52 InputController.RegisterEventForKey("shoot", Keys.X);
56 /// LoadContent will be called once per game and is the place to load
57 /// all of your content.
59 protected override void LoadContent()
61 // Create a new SpriteBatch, which can be used to draw textures.
62 spriteBatch = new SpriteBatch(GraphicsDevice);
64 Vector2 playerPosition = new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + GraphicsDevice.Viewport.TitleSafeArea.Height / 2);
66 Renderer.CheckIn(ActorFactory.CreateMainShip(playerPosition));
67 Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Positive, new Vector2(200, 200)));
68 Renderer.CheckIn(ActorFactory.CreateShip(Ship.Polarity.Negative, new Vector2(400, 200)));
72 /// UnloadContent will be called once per game and is the place to unload
75 protected override void UnloadContent()
77 // TODO: Unload any non ContentManager content here
81 /// Allows the game to run logic such as updating the world,
82 /// checking for collisions, gathering input, and playing audio.
84 /// <param name="gameTime">Provides a snapshot of timing values.</param>
85 protected override void Update(GameTime gameTime)
87 if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
90 // TODO: Add your update logic here
92 InputController.UpdateInput();
93 ActorManager.Update(gameTime);
95 base.Update(gameTime);
99 /// This is called when the game should draw itself.
101 /// <param name="gameTime">Provides a snapshot of timing values.</param>
102 protected override void Draw(GameTime gameTime)
104 GraphicsDevice.Clear(Color.White);
108 Renderer.Draw(spriteBatch);